package cn.wolfcode.rest.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("test")
public class TestController {
    //params属性,要求请求的时候必须带上指定的参数名和参数值
    @GetMapping(value = "params",params = "name=admin")
    public void test(){
        System.out.println("凡王之血,必以剑终");
    }

    //请求的时候必须带上指定的头信息才能访问,否则就无法访问
    @RequestMapping(value = "headers",headers = "content-type=application/json")
    public void test1(){
        System.out.println("-----------headers----");
    }
    @RequestMapping(value = "headers",headers = "content-type=text/html")
    public void test2(){
        System.out.println("------headers2----------");
    }

    //消费前台传过来的数据
    //相当于配置了headers = "content-type=application/json",如果请求头中没有带content-type=application/json,就不能访问
    @RequestMapping(value = "consumes",consumes = "application/json")
    public void test3(){
        System.out.println("-------------------consumes1");
    }

    @RequestMapping(value = "consumes",consumes = "text/html")
    public void test4(){
        System.out.println("------consumes2----------");
    }

    //生成数据给后台
    //相当于配置了headers:accept=application/json,如果请求头没有带accept也能访问,但是如果带了accept,不匹配就进不来
    @RequestMapping(value = "produces",produces = "application/json")
    public void test5(){
        System.out.println("-----------------produces1");
    }

    @RequestMapping(value = "produces",produces = "text/html")
    public void test6(){
        System.out.println("-----------------produces2");
    }

}
